class Solution {
public:
    double myPow(double x, int n) {
        double long ret=dfs(x,n);
        if(n<0) return 1/ret;
        else return ret;
    }
    double dfs(double x, int n)
    {
        if(n==0) 
        {
          return 1;  
        }
        long double tmp=dfs(x,n/2);
        if(n%2==0)
            return tmp*tmp;
        else
            return tmp*tmp*x;
        
        
        return 0;
    }
};
